package com.zerro.litez.compiler.processor.parser;

import javax.lang.model.element.TypeElement;
import java.util.HashMap;
import java.util.Map;

public class EnumParser extends AbstractClassParser {


    private static final Map<String, TypeElement> supportedEnumMap = new HashMap<>();

    public EnumParser(TypeElement parsingElement) {
        super(parsingElement);
        onParse();
    }

    @Override
    protected void onParse() {

        if (existField()) {
            supportedEnumMap.put(parsingElement.getQualifiedName().toString(), parsingElement);
        } else {
            throw new RuntimeException("Enum <" + parsingElement + "> 中没有任何常量");
        }
    }

    private boolean existField(){
        return !parsingElement.getEnclosedElements().isEmpty();
    }

    public static Map<String, TypeElement> getSupportedEnumMap() {
        return supportedEnumMap;
    }
}
